﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using System.Reflection;
using System.Diagnostics;

namespace Xinnos.Lca.Yacht.Analyzer.View
{
    internal class ModuleViewModel:INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        private string mName = null;
        private string mVersion = null;
        private string mCompany = null;

        public string Name
        {
            get { return mName; }
            set
            {
                mName = value;
                RaisePropertyChanged("Name");
            }
        }
        public string Version
        {
            get { return mVersion; }
            set
            {
                mVersion = value;
                RaisePropertyChanged("Version");
            }
        }
        public string Company
        {
            get { return mCompany; }
            set
            {
                mCompany = value;
                RaisePropertyChanged("Company");
            }
        }

        public ModuleViewModel() { }

        public ModuleViewModel(string strPath)
        {
            FileVersionInfo _file = FileVersionInfo.GetVersionInfo(strPath);
            this.Name = _file.ProductName;
            this.Version = _file.FileVersion;
            this.Company = _file.CompanyName;
        }

        private void RaisePropertyChanged(string strPropertyName)
        {
            PropertyChangedEventHandler _handler = this.PropertyChanged;
            if (null != _handler) _handler(this, new PropertyChangedEventArgs(strPropertyName));
        }
    }
}
